package servlets;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import vo.VentaVO;
import facade.BD;

/**
 * Servlet implementation class ListarVentas
 */
@WebServlet("/ListarVentas")
public class ListarVentas extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ListarVentas() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 
		BD bd = BD.getInstance();
		List<VentaVO> ventas=bd.getVentasUsuario();
		request.setAttribute("ventas", ventas);
    	String jspPage = "/ListaOrdenes.jsp";
    	
    	dispatch(jspPage, request, (HttpServletResponse) ventas);
    	}

    	protected void dispatch(String jsp, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	if (jsp != null)
    	{
    	    RequestDispatcher rd = request.getRequestDispatcher(jsp);
    	    rd.forward(request, response);
    	}

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
